package com.shen.JUC.sup;

import java.util.concurrent.CountDownLatch;

//计数器
public class CountDown {
    public static void main(String[] args) throws InterruptedException {
        //必须要执行任务的时候再使用
        CountDownLatch count = new CountDownLatch(5);
        for (int i = 0; i < 6; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "go out");
                count.countDown();//数量-1
            }).start();
        }
        count.await();//等待计数器归0，然后再向下执行
        System.out.println("Close door");
    }
}
